package com.mapull.primitive;

/**
 * @author Mapull
 * @date 2024-04-20
 */
public class SimpleDouble {

    public static void main27(String[] args) {
        Double d1 = Double.valueOf(1.234);
        Double d2 = Double.valueOf(1.234);
        System.out.println(d1 == d2);
    }
    public static void main26(String[] args) {
        Double d1 = Double.valueOf(1.234);
        String str1 = d1.toString();
        Double d2 = Double.valueOf(Double.NaN);
        String str2 = d2.toString();
    }
    public static void main25(String[] args) {
        String str1 = Double.toString(1.234);
        System.out.println(str1);
        String str2 = Double.toString(Double.NaN);
        System.out.println(str2);
        String str3 = Double.toString(Double.POSITIVE_INFINITY);
        System.out.println(str3);
        String str4 = Double.toString(Double.MAX_VALUE);
        System.out.println(str4);
        String str5 = Double.toString(0.00);
        System.out.println(str5);
        String str6 = Double.toString(-0.00);
        System.out.println(str6);
    }

    public static void main24(String[] args) {
        String str1 = Double.toHexString(3.14159d);
        System.out.println(str1);
        String str2 = Double.toHexString(Double.NaN);
        System.out.println(str2);
        String str3 = Double.toHexString(Double.POSITIVE_INFINITY);
        System.out.println(str3);
        String str4 = Double.toHexString(Double.MAX_VALUE);
        System.out.println(str4);
        String str5 = Double.toHexString(0.00);
        System.out.println(str5);
    }
    public static void main23(String[] args) {
        double d1 = Double.parseDouble("2.5d");
        double d2 = Double.parseDouble("9.99f");
        System.out.println(d1);
        System.out.println(d2);

        double d3 = Double.parseDouble("NaN");
        double d4 = Double.parseDouble("Infinity");
        System.out.println(d3);
        System.out.println(d4);
    }

    public static void main21(String[] args) {
        double d1 = Double.parseDouble("1A"); //java.lang.NumberFormatException: For input string: "1A"
        double d2 = Double.parseDouble("两"); //java.lang.NumberFormatException: For input string: "两"
        double d3 = Double.parseDouble("zero");//java.lang.NumberFormatException: For input string: "zero"
    }
    public static void main20(String[] args) {
        double d1 = Double.parseDouble("1.234");
        double d2 = Double.parseDouble("-2.345");
        double d3 = Double.parseDouble("+999");
        double d4 = Double.parseDouble("0x4.0p-1");
        System.out.println(d1);
        System.out.println(d2);
        System.out.println(d3);
        System.out.println(d4);
    }

    public static void main19(String[] args) {
        Double d = Double.valueOf("3.14159");
        short b = d.shortValue();
        Double d1 = Double.valueOf(Double.MAX_VALUE);
        short b1 = d1.shortValue();
        Double d2 = Double.valueOf(Double.MIN_VALUE);
        short b2 = d2.shortValue();
        Double d3 = Double.valueOf(Double.NaN);
        short b3 = d3.shortValue();
        System.out.println(d + " short value " + b);
        System.out.println(d1 + " short value " + b1);
        System.out.println(d2 + " short value " + b2);
        System.out.println(d3 + " short value " + b3);
    }
    public static void main18(String[] args) {
        Double d = Double.valueOf("12");
        double b = d.doubleValue();
        Double d1 = Double.valueOf("-5.66");
        double b1 = d1.doubleValue();
        Double d2 = Double.valueOf(Double.NaN);
        double b2 = d2.doubleValue();
        System.out.println(d + " double value " + b);
        System.out.println(d1 + " double value " + b1);
        System.out.println(d2 + " double value " + b2);
    }

    public static void main17(String[] args) {
        Double d = Double.valueOf("-12.0");
        int b = d.intValue();
        Double d1 = Double.valueOf("3.14");
        int b1 = d1.intValue();
        Double d2 = Double.valueOf("6.99");
        int b2 = d2.intValue();
        Double d3 = Double.valueOf(Double.MAX_VALUE);
        int b3 = d3.intValue();
        System.out.println(d + " int value " + b);
        System.out.println(d1 + " int value " + b1);
        System.out.println(d2 + " int value " + b2);
        System.out.println(d3 + " int value " + b3);
    }

    public static void main16(String[] args) {
        Double d = Double.valueOf("12.0");
        byte b = d.byteValue();
        Double d1 = Double.valueOf("3.14");
        byte b1 = d1.byteValue();
        Double d2 = Double.valueOf("6.99");
        byte b2 = d2.byteValue();
        Double d3 = Double.valueOf("1234");
        byte b3 = d3.byteValue();
        System.out.println(d + " byte value " + b);
        System.out.println(d1 + " byte value " + b1);
        System.out.println(d2 + " byte value " + b2);
        System.out.println(d3 + " byte value " + b3);
    }

    public static void main15(String[] args) {
        Double d1 = Double.valueOf(Double.NaN);
        boolean b1 = d1.isNaN();
        boolean b2 = Double.isNaN(d1);
        System.out.println(d1 + "  isNaN 1 " + b1 + " isNaN 2 " + b2);
        Double d3 = Double.valueOf(Double.POSITIVE_INFINITY);
        boolean b3 = d3.isNaN();
        boolean b4 = Double.isNaN(d3);
        System.out.println(d3 + "  isNaN 3 " + b3 + " isNaN 4 " + b4);
    }
    public static void main14(String[] args) {
        Double d1 = Double.valueOf("-0.0");
        boolean b1 = Double.isInfinite(d1);
        System.out.println(d1 + " isInfinite " + b1);

        Double d2 = Double.valueOf(Double.MAX_VALUE);
        boolean b2 = Double.isInfinite(d2);
        System.out.println(d2 + " isInfinite " + b2);
        System.out.println(d2 + " isInfinite " + d2.isInfinite());


        Double d3 = Double.valueOf(Double.POSITIVE_INFINITY);
        boolean b3 = Double.isInfinite(d3);
        System.out.println(d3 + " isInfinite " + b3);
        System.out.println(d3 + " isInfinite " + d3.isInfinite());
    }

    public static void main13(String[] args) {
        Double d1 = Double.valueOf("-0.0");
        Double d2 = Double.valueOf("+0.0");
        System.out.println(d1.equals(d2));

        Double d3 = Double.valueOf(Double.NaN);
        Double d4 = Double.valueOf(Double.NaN);
        System.out.println(d3.equals(d4));
    }

    public static void main12(String[] args) {
        Double d1 = Double.valueOf("1234.0");
        Double d2 = Double.valueOf("1234");
        Double d3 = Double.valueOf("123");
        boolean b1 = d1.equals(d2);
        boolean b2 = d1.equals(d3);
        System.out.println(b1);
        System.out.println(b2);
    }

    public static void main11(String[] args) {
        Double d1 = Double.valueOf("1234.0");
        Double d2 = Double.valueOf("-666.99");
        Double d3 = Double.NaN;
        Double d4 = Double.valueOf(Double.MIN_VALUE);
        Double d5 = Double.NaN;
        int i1 = d1.compareTo(d3);
        int i2 = d2.compareTo(d3);
        int i3 = d4.compareTo(d3);
        int i4 = d5.compareTo(d3);
        System.out.println(i1);
        System.out.println(i2);
        System.out.println(i3);
        System.out.println(i4);
    }

    public static void main10(String[] args) {
        Double d1 = Double.valueOf("1.234");
        Double d2 = Double.valueOf("99");
        Double d3 = Double.valueOf("-0.01");
        Double d4 = Double.valueOf("+99");
        int i1 = Double.compare(d1, d2);
        int i2 = Double.compare(d1, d3);
        int i3 = Double.compare(d2, d4);
        System.out.println(i1);
        System.out.println(i2);
        System.out.println(i3);
    }

    public static void main9(String[] args) {
        Double d1 = Double.valueOf("1.234");
        Double d2 = Double.valueOf("99");
        Double d3 = Double.valueOf("-0.01");
        Double d4 = Double.valueOf("+99");
        int i1 = d1.compareTo(d2);
        int i2 = d1.compareTo(d3);
        int i3 = d2.compareTo(d4);
        System.out.println(i1);
        System.out.println(i2);
        System.out.println(i3);
        System.out.println(d2 == d4);
    }

    public static void main7(String[] args) {
        Double d1 = Double.valueOf("1A");//java.lang.NumberFormatException: For input string: "1A"
        Double d2 = Double.valueOf("0x23");//java.lang.NumberFormatException: For input string: "0x23"
        Double d3 = Double.valueOf("大");//java.lang.NumberFormatException: For input string: "大"
    }

    public static void main8(String[] args) {
        Double d1 = Double.valueOf("0x4.0p-2");
        Double d2 = Double.valueOf("0x2.0p2");
        System.out.println(d1);
        System.out.println(d2);
    }

    public static void main6(String[] args) {
        Double d1 = Double.valueOf("0.22d");
        Double d2 = Double.valueOf("6.7f");
        System.out.println(d1);
        System.out.println(d2);
    }

    public static void main5(String[] args) {
        Double d1 = Double.valueOf("1.234");
        Double d2 = Double.valueOf("99");
        Double d3 = Double.valueOf("-0.01");
        Double d4 = Double.valueOf("+1.08");
        System.out.println(d1);
        System.out.println(d2);
        System.out.println(d3);
        System.out.println(d4);
    }

    public static void main4(String[] args) {
        Double d1 = Double.valueOf(2.34);
        Double d2 = Double.valueOf(66);
        Double d3 = Double.valueOf(-0.9);
        System.out.println(d1);
        System.out.println(d2);
        System.out.println(d3);
    }

    public static void main3(String[] args) {
        double minValue = Double.MIN_VALUE;
        double maxValue = Double.MAX_VALUE;
        double minNormal = Double.MIN_NORMAL;
        double infinity = Double.POSITIVE_INFINITY;
        double negativeInfinity = Double.NEGATIVE_INFINITY;
        double naN = Double.NaN;
        int maxExponent = Double.MAX_EXPONENT;
        int minExponent = Double.MIN_EXPONENT;
        int size = Double.SIZE;
        Class<Double> type = Double.TYPE;
        System.out.println(minValue);
        System.out.println(maxValue);
        System.out.println(minNormal);
        System.out.println(infinity);
        System.out.println(negativeInfinity);
        System.out.println(naN);
        System.out.println(maxExponent);
        System.out.println(minExponent);
        System.out.println(size);
        System.out.println(type);
    }

    public static void main2(String[] args) {
        Double d1 = new Double("456");
        Double d2 = new Double("-4.567");
        Double d3 = new Double("+8.9");
        System.out.println(d1);
        System.out.println(d2);
        System.out.println(d3);
        Double d = new Double("1A");
    }

    public static void main1(String[] args) {
        Double d1 = new Double(123);
        Double d2 = new Double(12.3);
        Double d3 = new Double(-1.23);
        System.out.println(d1);
        System.out.println(d2);
        System.out.println(d3);
    }
}
